﻿/*========================== 
 * @author 郑金泉
 * @desc 实体字段接口
 * ========================= */
using System;
using System.Collections.Generic;
using System.Text;

using Obsidian.Data.Sql;

namespace Obsidian.Edm
{
    public interface IModelField
    {
        /// <summary>
        /// 是否已被重赋值
        /// </summary>
        bool Assigned { get; set; }

        /// <summary>
        /// 所属Model
        /// </summary>
        IModel Model { get; }

        /// <summary>
        /// 获得映射字段
        /// </summary>
        DbField GetDbField();

        FieldType Type { get; }

        /// <summary>
        /// 是否是空值状态
        /// </summary>
        bool IsNull { get; }

        /// <summary>
        /// 是否是列表字段
        /// </summary>
        bool IsList { get; }

        /// <summary>
        /// 别名
        /// </summary>
        string Alias { get; }

        /// <summary>
        /// 设置Object值
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        IModel Set(object value);

        /// <summary>
        /// 尝试设置object值
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        bool TrySet(object value);

        /// <summary>
        /// 设置为空值状态
        /// </summary>
        IModel SetNull();

        /// <summary>
        /// Object值
        /// </summary>
        object OValue { get; }

        string ToString();


        #region Compare

        ISqlCondition Compare(string compareOperator, object value);

        ISqlCondition Compare(string compareOperator, ModelField targetField);

        ISqlCondition Equals(object value);

        ISqlCondition Equals(ModelField targetField);

        #endregion

        #region In

        ISqlCondition In(object[] values);
        
        ISqlCondition In(string[] values);

        ISqlCondition In(int[] values);

        ISqlCondition In(long[] values);

        ISqlCondition In<T>(ICollection<T> values);

        #endregion

        #region NotIn

        ISqlCondition NotIn(object[] values);

        ISqlCondition NotIn(string[] values);

        ISqlCondition NotIn(int[] values);

        ISqlCondition NotIn(long[] values);

        ISqlCondition NotIn<T>(ICollection<T> values);

        #endregion

        #region Like

        ISqlCondition Like(string keyWord);

        ISqlCondition Like(string keyWord, LikeType likeType);

        ISqlCondition Like(ICollection<string> keyWords);

        ISqlCondition Like(ICollection<string> keyWords, LogicalOperator logicalOperator, LikeType likeType);

        #endregion

        #region Between

        ISqlCondition Between(object valStart, object valEnd);

        #endregion

        #region Contanis

        ISqlCondition Contanis(string matchingString);

        #endregion
    }
}
